Loading...
 

Charts (WebWidget)

Charts (WebWidget)

This web widget is used to create different types of charts, starting with pie charts, bar charts and complex line charts in a simple way.

Circle or ring diagrams visually represent the percentage ratios of the data to each other as segments of a circle or ring. The data components are marked in different colours or with deposited graphic patterns, so that the percentage ratios of the data can be seen at first glance. Background patterns are especially useful for people who are colour blind or for black and white printing.

A ring diagram could consist of several rings, each ring representing a further dimension of the data. For example, the percentage of a data set depending on the year in a two-year period could be represented as two nested rings, as the figure shows. Although nested circles can be used instead of nested rings, it has become established in practice that pie charts represent only a single set of data, while ring charts illustrate several comparable sets of data.

With the properties circumference and startAngle you can easily create a semicircle or semicircle diagram from a circle or ring diagram.

This WebWidget is so flexible that you can easily switch between the different variants by changing the corresponding parameter without having to write additional code.

Bar or column charts are used to illustrate the change in one or more discrete quantities over a variable (time span, categories, etc.) in a quantitative and comparable manner. The number of variables and their frequency should be kept small in order not to lose clarity, otherwise a line chart would be more suitable for representing larger data sets. If the quantitative data are not very relevant and only the percentage ratios should be shown, a pie chart is best.

It is possible to display bar charts horizontally, in which case some literature speaks of bar charts. For the sake of clarity, column and bar charts are referred to as bar charts in this article, regardless of their orientation.

Radar diagrams, also known as network diagrams, offer the possibility of displaying data on several star-shaped axes. The resulting graphs can be easily compared based on their shape, size and overlays. Therefore radar charts are often used for strategic decisions.

The Radar Chart WebWidget allows you to create radar charts in a very easy way, with a great freedom of display, from the background and border colours to the degree of curvature of the connecting lines.

Conventional line diagrams, also called curve diagrams, graphically represent a (functional) relationship between two characteristics.

If statistical data are available, the so-called scatter plots are best suited to investigate and illustrate the relationships between the statistical value pairs.

Bubble charts differ from scatter charts in that they are able to show three characteristics instead of only two. However, because the third characteristic is illustrated by the radius of a point, bubble charts cannot represent as many values as scatter charts.

Pie chart of sample data
Pie chart of sample data
Ring diagram of two dimensions
Ring diagram of two dimensions
Semicircle diagram of sample data
Semicircle diagram of sample data
Bar chart of sample data
Bar chart of sample data
Bar chart of sample data
Bar chart of sample data
Radar plot of sample data
Radar plot of sample data
Line chart of sample data
Line chart of sample data
Different forms of representation
Different forms of representation of the line charts
Scatter diagram
Scatter plot
Bubble diagram
Bubble chart

Use

Web(ChartsWebWidget, APP("charts.html"), 0, 0, 800, 600)

Dependencies

  • charts.html
  • charts-directive.js
  • dependencies/
    • Chart.bundle.min.js

Message interface

When describing the direction, the WebWidget is divided into its two components. The WebWidget implemented in HTML, which implements the presentation logic and user interaction in the browser and the WebWidget implemented in InstantView, which supplies the other side with the data from ClassiX and controls it.

NameParametersDescription
Push News (IV→HTML)
dataDataThis message passes a data object to the Web widget as CX_JSON_OBJECT and contains the data sets to be drawn.
optionsOptionsThis message passes an Options object to the Web widget as CX_JSON_OBJECT and contains general display options and can be sent any number of times, both before and after a data message. Successive options messages are complementary to each other.
axesAxesThis message passes an Axes object to the Web widget as CX_JSON_OBJECT and contains settings for an axis and can be sent as often as required, both before and after a data message. Successive axes messages for the same axis overwrite each other and are not complementary.
Events (HTML→IV)
INITIALIZE_SOCKET-The first message that the WebWidget sends once it has initialised. This indicates that the WebWidget is ready to receive and process push messages.
MOUSE_CLICK_SOCKETDataPoint

InstantView is informed that a point/segment/bar (so-called data point) in the graph has been clicked. A data point is transferred as a DataPoint object, identified by its coordinates and the index of its data set.

Caution: The transposition of the data display does not affect the indexes and coordinates in the DataPoint object. This is useful for correctly associating the clicked data again.

The Data Object

The data object is of type CX_JSON_OBJECT and contains the data to be displayed. Highlighted fields are mandatory.

FieldTypeDescription
datasetsARRAY (Dataset)Each dataset object represents a data set and its display parameters.
redrawBoolean

If set to false, this message complements old data messages and does not overwrite them. By default, data messages overwrite the previous ones.

If redraw is set to false, the datasets are associated based on their order and the points in the datasets are composed. For example, to change only the second dataset in an update message, the first dataset must be listed as an empty object { }, { dataset 2 ...}, .... This is only necessary to preserve the order.

The dataset object

FieldTypeDescription
pointsARRAY(ARRAY(Number|String))

A two-dimensional array, each inner array representing an n-value tuple. The values can be either numeric or alphanumeric, depending on the axis definition. Time and date information is passed as formatted strings.

If a tuple consists of only one dimension, then it can be written as a loose number. Loose numbers are automatically added to tuples, where the first element in the tuple is the index starting with 1. This index then refers to the nth category in the case of a category axis.

functionFunction

If you do not want to specify any data points, but want the data points to be generated automatically from a function, you can specify this using a function object.

In this case, the points under points (if any) are combined with the generated points. The points under points overwrite the generated points.

colorStringThe main colour representing the dataset, in an HTML-compliant format as a string (e.g. "red", "#ff0000", "rgb(255, 0, 0)" or "hsl(0, 100%, 50%)") If no colour is specified, MorphIT automatically completes it with a colour from predefined colour set depending on the MorphIT style applied.
labelStringTextual description of the displayed data (graph), which appears in the legend and in the corresponding tooltips.
hiddenBooleanIf set, this data set is hidden in the chart, with the possibility for the user to show it at any time.
redrawBoolean

Is set to allow deviations from a negative general redraw setting. This is useful for vertical lines in the line chart to allow multiple points in a dataset on an x-coordinate when the other datasets are only added. (the other datasets have redraw

deleteBooleanIf redraw is set to false, this option allows you to delete the dataset completely from the diagram and not just hide it.
The following features apply to radar and line charts only
lineWidthNumberThe width of the drawn line in pixels.
dashedLineBooleanIf set, the line is drawn as a dashed line. By default the line is solid.
lineTensionNumberThis number determines the degree of curvature of the connecting lines in the graph. 0 is the default value and makes the connecting lines appear straight. For fractions of a tenth, the connecting lines can be drawn curved.
fillBoolean|Number

This option determines whether the graph associated with this dataset should have a background colour. The default value is TRUE. Possible other values are:

  • FALSE: no background colour
  • The index of a dataset starts with 0: filling up to the dataset with the given index.
bgColorStringThe background colour of a graph. It is advisable to select a partially transparent colour using the rgba format that matches the border colour. If not entered, this colour is automatically determined by colour, with a transparency of 80%.
showPointsBooleanIf set, the points are drawn on the lines. The default value is false for functions and true for discrete points.
The following properties only apply to line charts
monotone interpolationBooleanIf this option is set, monotony is ensured in the cubic interpolation. Monotonous interpolation is best for graphs that represent functions y = f(x). By default, this option is not enabled.
steppedLineBoolean|String

This option can take the following values:

  • FALSE : Standard. It is interpolated normally without forming a staircase function.
  • before' : forms a staircase function where the constant interpolation between two points (x, x+1) takes the value y(x).
  • after' : forms a staircase function where the constant interpolation between two points (x, x+1) takes the value y(x+1).

The function object

The data object is of type CX_JSON_OBJECT and contains the specification of a point generating function

FieldTypeDescription
expressionString

A mathematical expression in the form "f(x) = 5*sin(x) + 3x + a". All functions and constants of the library math.js are allowed. ( List of all functions - List of all constants )

constantsJSON Object

If expression contains constants, these must be defined as here. Example:

{ "a" : 15.6 }

startString | Number

The initial value of x with which the point generation starts. This can also be specified as a mathematical expression, e.g. "-2PI".

List of all constants

endString | Number

The final value of x, with which the point generation ends. This can also be specified as a mathematical expression, e.g. "2PI/2".

List of all constants

stepString | NumberThe step to iterate between start and end. If this is not specified, the step is one hundredth of the distance between min and max. This can also be given as a mathematical expression e.g. "PI/2".

The Axes object

FieldTypeDefault valueDescription
dimensionInteger-The settings are assigned to the axis with this dimension. 0 refers, for example, to the first dimension in the n-tuple of the data, etc.
typeString"linear"

This WebWidget supports four types of axes: linear, logarithmic, temporal and category axes.

A category axis is useful if there can be no intermediate values between the coordinates and the order is not important. "Distribution costs" and "Personnel costs" are categories that do not form an ordered continuity, unlike 'October 2019' and 'December 2019', which may have an intermediate value of 'November 2019'. Tuples refer to the categories with the index of one category starting with 1. The tuple (2, 45) thus refers to the second category and has the value 45.

The linear, logarithmic, and temporal axes are recommended if the corresponding data are available and have the advantage over the category axis that no categories need to be defined, but rather a continuous numerical stream is defined, which allows intermediate values without rearranging "categories".

Possible values: linear, logarithmic, time, category

labelString""The title of the axis. This is often used to indicate the unit.
gridLinesBooleantrueShows or hides the grid lines parallel to the axis.
stackedBooleanfalseThis is only relevant for the y-axis in bar and line charts and results in the bars of all datasets being stacked on top of each other at a common coordinate. In the line chart the same behaviour occurs, but in relation to the areas under a line (a dataset).
minNumber0

The value at which the axis should start regardless of the data limits.

This value is not taken into account in category axes.

maxNumberdynamic

The maximum value that the axis shows, regardless of the data limits. If this property is not explicitly specified, the maximum limit is determined dynamically using the data.

This value is not taken into account in category axes.

stepNumberdynamic

This property determines the size of the axis steps.

This value is not taken into account in time and category axes.

autoSkipBooleantrueAs a rule, as many labels are displayed on one axis as the free space allows, so there is no text overlap. To display all labels regardless of the free space, this option can be set to FALSE.
Properties only relevant for category axes
labelsARRAY(String)-If no labels are given in the data set, you could name the labels here. It is important to note that only as many bars (groups) are displayed as there are entries in this array. All other bars are ignored, so this property should be used with care.
Only properties relevant for logarithmic axes
useScientificNotationBooleantrueIf set, the labels of the axis are displayed in the scientific notation e.g. 5e+3, otherwise in the usual notation e.g. 5000.
Only properties relevant for time axes
timeUnitStringdynamic

If defined, the time axis is divided in the specified unit.

Possible values: millisecond, second, minute, hour, day, week, month, quarter, year

timeUnitFormatsString|TimeFormats. TimeFormatSpecifies the display format for the selected or dynamically determined time unit.
timeParserFormatStringautomaticallyThis string indicates how the time and date information should be interpreted. For all possible formats please refer to moment.js. If no format should be specified, all ISO 8601 formats are allowed which support moment.js.
tooltip formatString-By default, time and date information is displayed in tooltips in the same format as it is submitted. This option allows you to specify a different format for the tooltips. For all possible formats please refer to moment.js.
isoWeekdayBooleanTRUEIf timeUnit is set to "week", the week starts with Monday if this property is set, otherwise with Sunday.


The option object

FieldTypeDefault valueDescription
typeString'line'.

The type of the diagram as string from the following set:

  • Line chart: "line".
  • Bar chart: "bar".
  • Circular diagram: "pie
  • bubblediagram: "bubble
  • Scatter diagram: "scatter
  • Radar diagram: "radar
animationDurationNumber400The duration of the animation in milliseconds when the diagram is loaded. 0 would disable the animation.
legendPositionString"top"

The relative position of the legend. The following values are accepted:

top, down, right, left, hidden

showTooltipsBooleantrueEnables or disables the display of tooltips when the mouse points to a bar.
titleString""A textual title for the diagram.
titlePositionString"top"

The relative position of the title. The following values are accepted:

top, down, right, left

These options only apply to pie charts
circumferenceNumber2The span of the diagram as a multiple of π. 1 would create a semicircle. To change the start angle, see startAngle.
startAngleNumber- 0.5The angle of attack as a multiple of π, from which the diagram is drawn.
cutoutPercentageNumber0A number between 0 and 100 that indicates the percentage size of the inner section in the ring diagram. A pie chart has a 0-section, a ring chart can in practice have sections between 20 and 80 depending on the style of the application. For example, the ring chart shown here has a 30-section.
These options only apply to bar charts
horizontalBooleanfalseIf set, the bar chart is drawn horizontally.

The DataPoint object

This object is communicated to InstantView as a parameter for events and is used to identify a data point (point, bar, segment, etc.).

FieldTypeDescription
dataset indexNumberThe index of the amount of data starting with 0, which is always 0 if there is only one amount of data.
pointArrayThe coordinates of the data point as array.


The TimeFormat object

This object specifies the formats for time units when a time axis is to be used. For all possible formats please refer to moment.js.

UnitDefault valueExample
millisecond'h:mm:ss.SSS a'11:20:01.123 ON
second'h:mm:ss a'11:20:01 AM
minute'h:mm a'11:20 AM
hour"hA.11AM
dayMMM DSep 4
weekllSep 4 2015
monthMMM YYYYSep 2015
quarter
'[Q]Q - YYYY'
Q3 - 2015
year"YYYYY2015


Display options in the widget menu

The widget menu appears at the top right of the chart widget when the mouse hovers over the widget or the widget has the focus. It includes several display options that allow the end user to change chart types, bar chart orientation, axis settings and more to achieve the desired view of the data.

Some of these options, unlike most self-explanatory options, require brief explanation. Data transposition is used to no longer divide the data by datasets, but by the x-coordinate (all values of an x-coordinate are combined to one dataset each), which allows a different view of the data. With data normalisation the conversion of absolute values into relative values is possible. Relative values refer to the sum of all values of all datasets to one x-coordinate. A pie chart is normalised in its original form in this way.